var express = require('express');
var router = express.Router();



let bcrypt = require('../utils/bcrypt')


/* async function show(){
  //await 


  // try catch

  try{
    //await ....
  }catch(e){
    //处理错误
  }

}

let show = async function(){}

let show = async ()=>{} */

/* GET home page. */
router.get('/', async (req, res, next) => {

  // console.log(req.query,req.body,req.files)

  // let token = jwt.sign({username:'alex',_id:"asdfasdfsdf"});
  // console.log(token)

  // jwt.verify(token).then(decode=>console.log(decode))

  // res.send({err:0,data:'...'})
  // res.render('index', { title: 'Express' });

  /* mgdb.open({collectionName:'user'}).then((
    {collection,client})=>collection.find({}).toArray((err,result)=>console.log(result))
  ) */


  //async await    阻塞等待的是promise的结果
  // let {collection,client} = await mgdb.open({collectionName:'user'});
  // await collection.find({}).toArray((err,result)=>console.log(result));  不是promise请求
  // client.close()

  /* console.log(1)

  try{
    let {collection,client} = await mgdb.open({collectionName:'user324',url:'mongodb://2.3.2.3:27017'});
    console.log('ok',collection)
  }catch(e){
    console.log(5)
    console.log('err',e)
  } */

  let hash  = bcrypt.hashSync('alex123')
  console.log(hash)

  console.log(bcrypt.compareSync('alex321',hash));//false

  

});

module.exports = router;
